<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <router-view></router-view>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/vue-router/dist/vue-router.js"></script>
    <script>

        let Account = {
            template: "<div><h1>这是Account组件</h1> <router-view></router-view></div>"
        }

        let Login = {
            template: "<div><h2>这是Login组件</h2></div>"
        }

        let Register = {
            template: "<div><h2>这是Register组件</h2></div>"
        }


        let router = new VueRouter({
            routes: [
                {
                    path: "/account",
                    component: Account,
                    //children表示子路由，可以实现路由嵌套
                    children: [
                        {
                            // path之前不能加 / 

                            //  /account/login
                            path: "login",
                            component: Login
                        },
                        {
                            // /account/register
                            path: "register",
                            component: Register
                        }
                    ]
                }
            ]
        })

        var vm = new Vue({
            el: "#app",
            data: {
            },
            router
        })
    </script>
</body>

</html>